package com.kvest.fragmentsfinaltest.component;

import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;

/**
 * Created with IntelliJ IDEA.
 * User: r.belokon
 * Date: 29.03.13
 * Time: 16:16
 * To change this template use File | Settings | File Templates.
 */
public class CustomViewPager extends ViewPager {
    private boolean scrollable;

    public CustomViewPager(Context context) {
        super(context);
        scrollable = true;
    }

    public CustomViewPager(Context context, AttributeSet attrs) {
        super(context, attrs);
        scrollable = true;
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        return scrollable && super.onTouchEvent(event);

    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent event) {
        return scrollable && super.onInterceptTouchEvent(event);

    }

    public boolean isScrollable() {
        return scrollable;
    }

    public void setScrollable(boolean scrollable) {
        this.scrollable = scrollable;
    }
}
